<?php
 require_once '../action/DB_MySQL.php';
 $mysql = new DB_MySQL;
 $mysql->connect('localhost', 'baocao', 'root', '');                                             
?>
<?php
   if(isset($_POST[submit])){ 
      $ten=$_POST[ten];
      $gia=$_POST[gia];
      $loai=$_POST[loai];
      $noidung=htmlspecialchars_decode(mysql_real_escape_string($_POST[mota]));
      $ghichu=$_POST[ghichu];
      move_uploaded_file($_FILES['file']['tmp_name'],"../upload/".$_FILES['file']['name']);
                         $img=$_FILES['file']['name']; 
     
      $sql="INSERT INTO post VALUES('','{$loai}','1','{$ten}','{$noidung}','{$img}','admin','2012','0')";
      $mysql->query($sql);
   }
  
?>


<?php 
 include('header.php');
?>
  <div id="content">
   
     <form action="" method="post" enctype="multipart/form-data" id="them">
         <fieldset>
            <legend>Mời anh đăng tin !</legend>
            <p>
               <label>Phân loại</label>
               <select name="loai">
                  <option value="tintuc" >tintuc</option>
                  <option value="gioithieu" >gioithieu</option>
                </select>
            </p>
            <p>
               <label>Tiêu đề bài viêt</label>
               <input type="text" value="" name="ten" class="required" />
            </p>
            
             <p>
               <label>Nội dung</label>
               <textarea name="mota" class="required" style="float: left;"></textarea>
            </p>
            <p>
               <label>Ảnh</label>
               <input type="file" value="" name="file" class="required" />
            </p>
            <p id="bt">
               <input type="submit" value="Nhập" id="submit" name="submit" />
            </p>
         </fieldset>
     </form>
  </div>
  
<?php include('footer.php');?>